﻿using Microsoft.AspNetCore.Mvc;
using MyTodo.Api.Services.Interfaces;
using MyTodo.Shared.Dtos;
using MyTodo.Shared.Services;

namespace MyTodo.Api.Controllers;

/// <summary>
/// 待办事项控制器
/// </summary>
[ApiController]
[Route("api/[controller]/[action]")]
public class LoginController : ControllerBase
{
    private readonly ILoginService _service;

    public LoginController(ILoginService service)
    {
        _service = service;
    }

    [HttpGet]
    public async Task<ApiResponse> Login(string account, string password) => await _service.LoginAsync(account, password);

    [HttpPost]
    public async Task<ApiResponse> Register([FromBody] UserDto model) => await _service.RegisterAsync(model);
}
